
public class Threadtest{
private static class Thread1 {
    private static class MyRunnable implements Runnable{
        public volatile boolean quit = false;
        @Override
        public void run() {
            while(!quit)
            {
                System.out.println(Thread.currentThread().getName()+"我忙着干活呢！");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("什么？！没钱发工资？那我卖啥命呢！");
        }

    }

        public static void main(String[] args)throws InterruptedException {
            MyRunnable target = new MyRunnable();
            Thread thread = new Thread(target,"李四");
            System.out.println(Thread.currentThread().getName()+"让李四开始干活！");
            thread.start();
            thread.sleep(10000);

            System.out.println(Thread.currentThread().getName()+"告诉李四别干了，老板跑路了发不出工资！");
            thread.sleep(1000);
            target.quit = true;

        }
    }
}

